<template>
  <div class="dashboard-container">
    <div>学校：{{schoolNum}}</div>
    <div>学院：{{academyNum}}</div>
    <div>班级：{{classsNum}}</div>
    <div>学生：{{studentNum}}</div>
    <div>老师：{{teacherNum}}</div>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'Dashboard',
    data(){
      return{
        schoolNum:0,
        academyNum:0,
        classsNum:0,
        studentNum:0,
        teacherNum:0
      }
    },
    computed: {
      ...mapGetters([
        'name'
      ])
    },
    mounted(){
      this.$http.get('/api/users/add').then(res => {
        console.log('this.panels', res)
      })
      //全部东西都放在res那里。
      this.$http.post('/api/school/find').then(res =>{
        if(res&&res.length>0){
          this.schoolNum = res.length  
          console.log('res:',res)
        }
      })
      this.$http.post('/api/academy/find').then(res =>{
        if(res&&res.length>0){
          this.academyNum = res.length
          console.log('res:',res)
        }
      }) 
      this.$http.post('/api/classs/find').then(res =>{
        if(res&&res.length>0){
          this.classsNum = res.length
          console.log('res:',res)
        }
      }) 
      this.$http.post('/api/student/find').then(res =>{
        if(res&&res.length>0){
          this.studentNum = res.length
          console.log('res:',res)
        }
      }) 
      this.$http.post('/api/teacher/find').then(res =>{
        if(res&&res.length>0){
          this.teacherNum = res.length
          console.log('res:',res)
        }
      })    
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard {
    &-container {
      margin: 30px;
    }
    &-text {
      font-size: 30px;
      line-height: 46px;
    }
  }
</style>